<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});
Route::get('test', function (Request $request){
    $id = $request->get("id");
    $thatFile = \App\Files::whereId($id)->first();
    $result = \App\Http\Services\AiManager::aiDiagnose($thatFile);
    return response()->json($result);
});
/** 路由可用路由组，但不要使用闭包，闭包无法生成缓存文件 */
Route::group(['prefix'=>'mall'],function (){
    Route::get('getMerchantList', 'Api\MallController@getMerchantList');
    Route::get('getIndexBannerList', 'Api\MallController@getIndexBannerList');
    Route::get('getIndexButtonList', 'Api\MallController@getIndexButtonList');
    Route::get('getIndexAreaList', 'Api\MallController@getIndexAreaList');
    Route::get('getClassifyList', 'Api\MallController@getClassifyList');
    Route::get('getBuyingClassifyList', 'Api\MallController@getBuyingClassifyList');
    Route::get('getMerchantMedicineList', 'Api\MallController@getMerchantMedicineList');
    Route::get('getMedicineDetail', 'Api\MallController@getMedicineDetail');
    Route::post('addShopCart', 'Api\MallController@addShopCart');
    Route::get('getShopCart', 'Api\MallController@getShopCart');
    Route::post('deleteShopCart', 'Api\MallController@deleteShopCart');
    Route::get('searchMedicine', 'Api\MallController@searchMedicine');
    Route::post('buildOrder', 'Api\MallController@buildOrder');
    Route::post('previewOrder', 'Api\MallController@previewOrder');
    Route::get('getUserVipInfo', 'Api\MallController@getUserVipInfo');
    Route::get('getMerchantSupportDeliveryMethod', 'Api\MallController@getMerchantSupportDeliveryMethod');
    Route::get('handleGroupFailOrder',['as' => 'Api.Mall.handleGroupFailOrder','uses' => 'Api\MallController@handleGroupFailOrder']);
    Route::post('orderRefund',['as' => 'Api.Mall.handleGroupFailOrder','uses' => 'Api\MallController@orderRefund']);
    Route::any('refundBack',['as' => 'Api.Mall.refundBack','uses' => 'Api\MallController@refundBack']);

});
Route::group(['prefix'=>'crm'],function (){
    Route::get('getPublicCustomerClueList', 'Api\CrmController@getPublicCustomerClueList');
    Route::get('getMyCustomerList', 'Api\CrmController@getMyCustomerList');
    Route::get('getCustomerServiceList', 'Api\CrmController@getCustomerServiceList');
    Route::post('addServiceRecord', 'Api\CrmController@addServiceRecord');
    Route::post('pluckCustomer', 'Api\CrmController@pluckCustomer');


});

Route::get('getUserToken/{id}', 'Api\AuthController@getUserToken');

Route::group(['prefix'=>'ai'],function (){
    Route::post('getAiDiagnose', 'Api\AiController@getAiDiagnose');
    Route::get('getMyDiagnose', 'Api\AiController@getMyDiagnose');
    Route::get('getLastDiagnose', 'Api\AiController@getLastDiagnose');
    Route::get('getShopInfo', 'Api\AiController@getShopInfo');
});

Route::group(['prefix'=>'order'],function (){
    Route::post('userCancelOrder', 'Api\OrderController@userCancelOrder');
    Route::get('getMyCourseList', 'Api\OrderController@getMyCourseList');
    Route::get('getMyOrderList', 'Api\OrderController@getMyOrderList');
    Route::get('getMyOrderDetail', 'Api\OrderController@getMyOrderDetail');
    Route::post('confirmReceive', 'Api\OrderController@confirmReceive');
});
Route::group(['prefix'=>'other'],function (){
    Route::get('getOperatingCity', 'Api\OtherController@getOperatingCity');
    Route::get('getIndexMessage', 'Api\OtherController@getIndexMessage');
    Route::any('thirdPartyPlatformAuthHandle', 'Api\OtherController@thirdPartyPlatformAuthHandle');
    Route::any('thirdPartyPlatformMessageHandle/{app_id}', 'Api\OtherController@thirdPartyPlatformMessageHandle');
    Route::any('initMerchant', 'Api\OtherController@initMerchant');
    Route::get('getIndustryList','Api\OtherController@getIndustryList');
    Route::get('getClassify','Api\OtherController@getClassify');
    Route::any('test', 'Api\OtherController@test');
    Route::any('ceshi', 'Api\OtherController@ceshi');
});

Route::group(['prefix' => 'news'],function(){
    Route::get('getNewsList','Api\NewsController@getNewsList');
    Route::get('getNewsDetail','Api\NewsController@getNewsDetail');
    Route::post('releaseNewsComment','Api\NewsController@releaseNewsComment');
    Route::post('commentLikeAction','Api\NewsController@commentLikeAction');
    Route::post('favoriteNews','Api\NewsController@favoriteNews');
    Route::post('unFavoriteNews','Api\NewsController@unFavoriteNews');
    Route::post('likeNews','Api\NewsController@likeNews');
    Route::get('getNewsComment','Api\NewsController@getNewsComment');
    Route::get('getNewsClassifyList','Api\NewsController@getNewsClassifyList');
});

Route::group(['prefix'=>'auth'],function (){
    Route::any('wxAppLogin', 'Api\AuthController@wxAppLogin');
    Route::any('wxAppThirdLogin', 'Api\AuthController@wxAppThirdLogin');
    Route::any('buildQrcodeImg', 'Api\AuthController@buildQrcodeImg');
    Route::post('sendVerificationCode', 'Api\AuthController@sendVerificationCode');
    Route::post('bindingPhone', 'Api\AuthController@bindingPhone');
    Route::post('getWeChatPhone', 'Api\AuthController@getWeChatPhone');
    Route::post('directBindingPhone', 'Api\AuthController@directBindingPhone');
    Route::any('visitorLogin', 'Api\AuthController@visitorLogin');
});
Route::group(['prefix' => 'file'],function(){
    Route::post('upload-img',['as'=>'Api.File.upload','uses'=>'Api\ImageController@upload']);
    Route::post('editor-upload-img',['as'=>'Api.File.EditorUpload','uses'=>'Api\ImageController@editorUploadImg']);
    Route::post('upload-audio',['as'=>'Api.File.uploadAudio','uses'=>'Api\ImageController@uploadAudio']);
    Route::post('upload-video',['as'=>'Api.File.uploadVideo','uses'=>'Api\ImageController@uploadVideo']);
    Route::post('businessLicenseUpload',['as'=>'Api.File.businessLicenseUpload','uses'=>'Api\ImageController@businessLicenseUpload']);
    Route::get('show-image/{id}',['as'=>'Api.File.showImageById','uses'=>'Api\ImageController@showImageById']);
    Route::get('show-video/{id}',['as'=>'Api.File.showVideoById','uses'=>'Api\ImageController@showVideoById']);
    Route::get('reloadImages',['as'=>'Api.File.reloadImages','uses'=>'Api\ImageController@reloadImages']);
    Route::post('uploadBase64Image',['as'=>'Api.File.uploadBase64Image','uses'=>'Api\ImageController@uploadBase64Image']);
    Route::post('upload-user-photo',['as'=>'Api.File.uploadUserPhoto','uses'=>'Api\ImageController@uploadUserPhoto']);
});
Route::group(['prefix' => 'coupon'],function(){
    Route::get('getCouponList','Api\CouponController@getCouponList');
    Route::get('getCouponDetail','Api\CouponController@getCouponDetail');
    Route::post('couponReceive','Api\CouponController@couponReceive');

});
Route::group(['prefix' => 'ucenter'],function(){
    Route::get('getUserInfo','Api\UCenterController@getUserInfo');
    Route::get('setUserInfo','Api\UCenterController@setUserInfo');
    Route::post('joinAgentTeam','Api\UCenterController@joinAgentTeam');
    Route::get('getUserCoupon','Api\UCenterController@getUserCoupon');
    Route::get('getAboutUs','Api\UCenterController@getAboutUs');
    Route::get('getPersonalCooperationAgreement','Api\UCenterController@getPersonalCooperationAgreement');
    Route::get('getEnterpriseCooperationAgreement','Api\UCenterController@getEnterpriseCooperationAgreement');
    Route::get('getContactCustomerService','Api\UCenterController@getContactCustomerService');
    Route::get('getMyIntegralInfo','Api\UCenterController@getMyIntegralInfo');
    //企业内部用户设置名片信息
    Route::post('setPersonCardInfo','Api\UCenterController@setPersonCardInfo');
    Route::get('getPersonCardInfo','Api\UCenterController@getPersonCardInfo');
    Route::get('getPersonCardInfoByUserId','Api\UCenterController@getPersonCardInfoByUserId');
    Route::get('buildPersonCardShareImg','Api\UCenterController@buildPersonCardShareImg');

    Route::get('getAgentTeamList','Api\UCenterController@getAgentTeamList');
    Route::get('getAgentOrderList','Api\UCenterController@getAgentOrderList');
    Route::get('getSettleAccountsRecordList','Api\UCenterController@getSettleAccountsRecordList');

    Route::post('addUserAppointment','Api\UCenterController@addUserAppointment');

});

Route::group(['prefix' => 'teacher'],function(){
    Route::get('getTeacherList','Api\TeacherController@getTeacherList');
    Route::get('getTeacherClassify','Api\TeacherController@getTeacherClassify');

});

Route::group(['prefix' => 'course'],function(){
    Route::get('getCourseList','Api\CourseController@getCourseList');
    Route::get('getCourseDetail','Api\CourseController@getCourseDetail');
    Route::get('getPackageDetail','Api\CourseController@getPackageDetail');
    Route::get('getCourseContentList','Api\CourseController@getCourseContentList');
    Route::get('getCourseQuestion','Api\CourseController@getCourseQuestion');
    Route::get('answerQuestion','Api\CourseController@answerQuestion');
    Route::get('getMyGroupList','Api\CourseController@getMyGroupList');
    Route::get('getUserGroupDetail','Api\CourseController@getUserGroupDetail');

    Route::post('collectionCourse','Api\CourseController@collectionCourse');
    Route::get('getUserCollectionCourseList','Api\CourseController@getUserCollectionCourseList');
    Route::get('courseSharePoster','Api\CourseController@courseSharePoster');
    Route::get('courseSharePosterV2','Api\CourseController@courseSharePosterV2');
    Route::get('getSignQRCodeUrl','Api\CourseController@getSignQRCodeUrl');
    Route::post('courseSign','Api\CourseController@courseSign');
    Route::post('recordCourseStudyLength','Api\CourseController@recordCourseStudyLength');
    Route::get('generateSharePoster','Api\CourseController@generateSharePoster');
    Route::post('agentApply','Api\CourseController@agentApply');


});

Route::group(['prefix'=>'admin'],function (){

    Route::group([],function(){
        //basic
        Route::get('getUserList','Api\Admin\BasicController@getUserList');
        Route::get('getConsumeUserList','Api\Admin\BasicController@getConsumeUserList');
        Route::get('getVipUserList','Api\Admin\BasicController@getVipUserList');
        Route::get('getUserBuyCourseList','Api\Admin\BasicController@getUserBuyCourseList');
        Route::get('getIntegralRecordList','Api\Admin\BasicController@getIntegralRecordList');
        Route::get('getBannerList','Api\Admin\BasicController@getBannerList');
        Route::get('getBannerDetail','Api\Admin\BasicController@getBannerDetail');
        Route::post('setBanner','Api\Admin\BasicController@setBanner');
        Route::post('delBanner','Api\Admin\BasicController@delBanner');
        Route::get('getButtonList','Api\Admin\BasicController@getButtonList');
        Route::get('getButtonDetail','Api\Admin\BasicController@getButtonDetail');
        Route::post('setButton','Api\Admin\BasicController@setButton');
        Route::post('delButton','Api\Admin\BasicController@delButton');
        Route::get('getAboutUs','Api\Admin\BasicController@getAboutUs');
        Route::post('setAboutUs','Api\Admin\BasicController@setAboutUs');
        Route::get('getVideoStatus','Api\Admin\BasicController@getVideoStatus');
        Route::post('setVideoStatus','Api\Admin\BasicController@setVideoStatus');
        Route::get('getSectionUrl','Api\Admin\BasicController@getSectionUrl');
        Route::get('getAgentApplyList','Api\Admin\BasicController@getAgentApplyList');
        Route::post('reviewAgent','Api\Admin\BasicController@reviewAgent');
        Route::get('getContactCustomerService','Api\Admin\BasicController@getContactCustomerService');
        Route::post('setContactCustomerService','Api\Admin\BasicController@setContactCustomerService');
        Route::get('getPersonalCooperationAgreement','Api\Admin\BasicController@getPersonalCooperationAgreement');
        Route::post('setPersonalCooperationAgreement','Api\Admin\BasicController@setPersonalCooperationAgreement');
        Route::get('getEnterpriseCooperationAgreement','Api\Admin\BasicController@getEnterpriseCooperationAgreement');
        Route::post('setEnterpriseCooperationAgreement','Api\Admin\BasicController@setEnterpriseCooperationAgreement');
        Route::get('getAgentOrderList','Api\Admin\BasicController@getAgentOrderList');
        Route::get('getAgentList','Api\Admin\BasicController@getAgentList');
        Route::get('getAgentSettleAccountsRecordList','Api\Admin\BasicController@getAgentSettleAccountsRecordList');
        Route::post('addAgentSettleAccountsRecord','Api\Admin\BasicController@addAgentSettleAccountsRecord');
        Route::get('getUserAppointmentList','Api\Admin\BasicController@getUserAppointmentList');



        Route::post('sys/setNewsClassify','Api\Admin\SystemController@setNewsClassify');
        Route::post('sys/delNewsClassify','Api\Admin\SystemController@delNewsClassify');
        Route::post('sys/sendNewsByAdmin','Api\Admin\SystemController@sendNewsByAdmin');
        Route::get('sys/getNewsDetail','Api\Admin\SystemController@getNewsDetail');
        Route::get('sys/getNewsClassifyList','Api\Admin\SystemController@getNewsClassifyList');
        Route::get('sys/getIndustryList','Api\Admin\SystemController@getIndustryList');
        Route::post('sys/addIndustry','Api\Admin\SystemController@addIndustry');
        Route::get('sys/getNewsList','Api\Admin\SystemController@getNewsList');
        Route::post('sys/delNewsByAdmin','Api\Admin\SystemController@delNewsByAdmin');

        Route::get('sys/getAiRecords','Api\Admin\SystemController@getAiRecords');
        Route::get('sys/getAiScoreRule','Api\Admin\SystemController@getAiScoreRule');

    });

    Route::group(['prefix'=>'vip'],function(){
        Route::get('getUserVipList','Api\Admin\VipController@getUserVipList');
        Route::post('setUserVip','Api\Admin\VipController@setUserVip');

    });

    Route::group(['prefix'=>'order'],function(){
        Route::middleware('permission:admin_set_order')->post('setOrder','Api\Admin\OrderController@setOrder');
        Route::middleware('permission:admin_del_order')->post('delOrder','Api\Admin\OrderController@delOrder');
    });

    Route::group(['prefix'=>'course'],function(){
        Route::middleware('permission:course_list_select')->get('getCourseList','Api\Admin\CourseController@getCourseList');
        Route::middleware('permission:course_package_list_select')->get('getPackagesList','Api\Admin\CourseController@getPackagesList');
        Route::middleware('permission:course_type_list_select')->get('getCourseTypeList','Api\Admin\CourseController@getCourseTypeList');
        Route::middleware('permission:teacher_list_select')->get('getTeacherList','Api\Admin\CourseController@getTeacherList');
        Route::middleware('permission:group_activity_list_select')->get('getSystemGroupList','Api\Admin\CourseController@getSystemGroupList');
        Route::middleware('permission:group_activity_list_select')->get('getSystemGroupDetail','Api\Admin\CourseController@getSystemGroupDetail');
        Route::middleware('permission:course_list_select')->get('getCourseDetail','Api\Admin\CourseController@getCourseDetail');
        Route::get('getCourseSignRecord','Api\Admin\CourseController@getCourseSignRecord');
        Route::middleware('permission:course_package_list_select')->get('getPackagesDetail','Api\Admin\CourseController@getPackagesDetail');
        Route::get('getCourseJoinInList','Api\Admin\CourseController@getCourseJoinInList');

        Route::middleware('permission:order_list_select')->get('getOrderList','Api\Admin\CourseController@getOrderList');

        Route::middleware('permission:course_edit')->post('setCourse','Api\Admin\CourseController@setCourse');
        Route::middleware('permission:teacher_edit')->post('setTeacher','Api\Admin\CourseController@setTeacher');
        Route::middleware('permission:course_package_edit')->post('setPackages','Api\Admin\CourseController@setPackages');
        Route::middleware('permission:group_activity_edit')->post('setSystemGroup','Api\Admin\CourseController@setSystemGroup');
        Route::middleware('permission:course_type_edit')->post('setCourseType','Api\Admin\CourseController@setCourseType');

        Route::middleware('permission:set_teacher_classify')->post('setTeacherClassify','Api\Admin\CourseController@setTeacherClassify');
        Route::middleware('permission:set_teacher_classify')->post('delTeacherClassify','Api\Admin\CourseController@delTeacherClassify');
        Route::middleware('permission:teacher_delete')->post('delTeacher','Api\Admin\CourseController@delTeacher');
        Route::middleware('permission:course_type_delete')->post('delCourseType','Api\Admin\CourseController@delCourseType');
        Route::middleware('permission:group_activity_delete')->post('delSystemGroup','Api\Admin\CourseController@delSystemGroup');
        Route::middleware('permission:course_package_delete')->post('delPackages','Api\Admin\CourseController@delPackages');
        Route::middleware('permission:course_delete')->post('delCourse','Api\Admin\CourseController@delCourse');
        Route::post('delQuestion','Api\Admin\CourseController@delQuestion');
        Route::get('courseSign','Api\Admin\CourseController@courseSign');
        Route::get('getTeacherClassify','Api\Admin\CourseController@getTeacherClassify');
        Route::post('orderReview','Api\Admin\CourseController@orderReview');
        Route::post('uploadContract','Api\Admin\CourseController@uploadContract');
        Route::post('setOrderContract','Api\Admin\CourseController@setOrderContract');

    });

    Route::group(['prefix'=>'crm'],function(){
        Route::middleware('permission:clue_edit')->post('setCustomerClue','Api\Admin\CrmController@setCustomerClue');
        Route::middleware('permission:clue_delete')->post('delCustomerClue','Api\Admin\CrmController@delCustomerClue');
        Route::middleware('permission:clue_list_select')->get('getCustomerClueList','Api\Admin\CrmController@getCustomerClueList');
        Route::get('getCustomerServiceRecord','Api\Admin\CrmController@getCustomerServiceRecord');
        Route::post('setCustomerServiceStaff','Api\Admin\CrmController@setCustomerServiceStaff');
        Route::get('cancelFollowUp','Api\Admin\CrmController@cancelFollowUp');

    });


    //系统管理
    Route::post('signInUser', 'Api\Admin\AuthController@signInUser');
    Route::post('changePassword', 'Api\Admin\AuthController@changePassword');
    Route::any('loginOut', 'Api\Admin\AuthController@loginOut');
    Route::get('getAdminUserInfo', 'Api\Admin\AuthController@getAdminUserInfo');
    Route::middleware('permission:admin_list_select')->get('adminList', 'Api\Admin\AuthController@adminList');
    Route::middleware('permission:admin_list_select')->get('adminSet', 'Api\Admin\AuthController@adminSet');
    Route::get('getMyPermission', 'Api\Admin\AuthController@getMyPermission');
    Route::middleware('permission:role_list_select')->get('roleList', 'Api\Admin\AuthController@roleList');
    Route::middleware('permission:role_list_select')->get('roleSet', 'Api\Admin\AuthController@roleSet');
    Route::middleware('permission:admin_edit')->post('changeAdminStatus', 'Api\Admin\AuthController@changeAdminStatus');
    Route::middleware('permission:admin_edit')->post('setAdmin', 'Api\Admin\AuthController@setAdmin');
    Route::middleware('permission:admin_delete')->post('delAdmin', 'Api\Admin\AuthController@delAdmin');
    Route::middleware('permission:role_edit')->post('setRole', 'Api\Admin\AuthController@setRole');
    Route::middleware('permission:role_delete')->post('delRole', 'Api\Admin\AuthController@delRole');
    Route::middleware('permission:permission_select')->get('permissionsList', 'Api\Admin\AuthController@permissionsList');

    Route::middleware('permission:coupon_list_select')->get('getCouponList', 'Api\Admin\CouponController@getCouponList');
    Route::middleware('permission:coupon_list_select')->get('getCouponDetail', 'Api\Admin\CouponController@getCouponDetail');
    Route::middleware('permission:coupon_edit')->post('setCoupon', 'Api\Admin\CouponController@setCoupon');
    Route::middleware('permission:coupon_delete')->post('delCoupon', 'Api\Admin\CouponController@delCoupon');

    Route::middleware('permission:staff_list_select')->get('getStaffList', 'Api\Admin\StaffController@getStaffList');
    Route::middleware('permission:staff_edit')->post('setStaff', 'Api\Admin\StaffController@setStaff');
    Route::middleware('permission:staff_delete')->post('delStaff', 'Api\Admin\StaffController@delStaff');
    Route::get('inviteRegisterList', 'Api\Admin\StaffController@inviteRegisterList');
    Route::get('inviteBuyList', 'Api\Admin\StaffController@inviteBuyList');

    Route::post('staffLogin', 'Api\Admin\AuthController@staffLogin');
    Route::post('changeAppointmentStatus', 'Api\Admin\BasicController@changeAppointmentStatus');

});
Route::group(['prefix'=>'payment'],function (){
    Route::post('weChatPayment',['as'=>'Api.Payment.weChatPayment','uses'=>'Api\PaymentController@weChatPayment']);
    Route::get('getPayQrCode',['as'=>'Api.Payment.getPayQrCode','uses'=>'Api\PaymentController@getPayQrCode']);
    Route::get('getPayStatus',['as'=>'Api.Payment.getPayStatus','uses'=>'Api\PaymentController@getPayStatus']);
    Route::any('WeChatPayCallback',['as'=>'Api.Payment.WeChatPayCallback','uses'=>'Api\PaymentController@WeChatPayCallback']);
});

